<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商品标识" prop="spbs">
        <el-input v-model="queryParams.spbs" placeholder="请输入商品标识" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="ISBN" prop="tm">
        <el-input v-model="queryParams.tm" placeholder="请输入ISBN" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="书名" prop="sm">
        <el-input v-model="queryParams.sm" placeholder="请输入书名" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="作者" prop="zyz">
        <el-input v-model="queryParams.zyz" placeholder="请输入作者" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="infoList" border>
      <el-table-column label="id" align="center" prop="id" width="120px"/>
      <el-table-column label="门店标识" align="center" prop="stordId" />
      <el-table-column label="商品标识" align="center" prop="spbs" />
      <el-table-column label="ISBN" align="center" prop="tm" />
      <el-table-column label="书名" align="center" prop="sm" />
      <el-table-column label="作者" align="center" prop="zyz" />
      <el-table-column label="出版年月" align="center" prop="cbrq" />
      <el-table-column label="楼层" align="center" prop="floor">
        <template slot-scope="scope">
          {{scope.row.floor}} - {{scope.row.jwh}}
        </template>
      </el-table-column>
      <el-table-column label="出版社" align="center" prop="cbsmc" />
      <el-table-column label="营销系类代码" align="center" prop="yxxldm" />
      <el-table-column label="定价" align="center" prop="dj" />
      <el-table-column label="折扣价" align="center" prop="discount" />
      <el-table-column label="在架数" align="center" prop="zjs" />
      <el-table-column label="图片" align="center" prop="imagePath" />
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  </div>
</template>

<script>
import { listInfo } from "@/api/erp/info";

export default {
  name: "BookInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 图书西信息表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        spbs: null,
        tm: null,
        sm: null,
        zyz: null,
        cbrq: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询图书西信息列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        stordId: null,
        spbs: null,
        tm: null,
        sm: null,
        zyz: null,
        cbrq: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
